<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://xmlns.jcp.org/jsf/passthrough"
                template="../template/layout.xhtml">

    <ui:define name="title">
        Add a user
    </ui:define>

    <ui:define name="content">
        <section class="admin add-user admin-form">
            <h:form id="user-add-form">
                <h2>Create a new user</h2>
                <div class="line">
                    <h:inputText value="#{userBean.tmpUser.email}"
                                 id="email"
                                 validatorMessage="Invalid email address"
                                 p:placeholder="Email"
                                 p:autofocus="autofocus" />
                    <span class="error red"><h:message for="email" /></span>
                </div>
                <div class="line">
                    <h:inputText value="#{userBean.tmpUser.password}"
                                 id="password"
                                 p:placeholder="Password" />
                    <span class="error red"><h:message for="password" /></span>
                </div>
                <div class="line">
                    <h:inputText value="#{userBean.tmpUser.firstname}"
                                 id="firstname"
                                 p:placeholder="Firstname" />
                    <span class="error red"><h:message for="firstname" /></span>
                </div>
                <div class="line">
                    <h:inputText value="#{userBean.tmpUser.lastname}"
                                 id="lastname"
                                 p:placeholder="Lastname" />
                    <span class="error red"><h:message for="lastname" /></span>
                </div>
                <div class="line">
                    <label for="role">Role</label>
                    <h:selectOneMenu value="#{userBean.tmpRole}" id="role">
                        <f:selectItem id="user" itemLabel="USER" itemValue="User" />
                        <f:selectItem id="admin" itemLabel="ADMIN" itemValue="Admin" />
                    </h:selectOneMenu>
                    <span class="error red"><h:message for="role" /></span>
                </div>
                <div class="submit">
                    <h:commandButton value="Submit" action="#{userBean.addUser}" class="button" />
                </div>
            </h:form>
        </section>
    </ui:define>
</ui:composition>